﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DHQGHN.DAL.Common;
using DHQGHN.DAL.DAO.Admin;
using DHQGHN.DAL.Models.Admin;

namespace DHQGHN.DAL.BO.Admin
{
    public class DisabilityStatusBO: BaseBO
    {
        #region field in database
        public const string FIELD_DISABILITY_STATUS_ID = "DISABILITY_STATUS_ID";
        public const string FIELD_CODE = "CODE";
        public const string FIELD_NAME = "NAME";
        public const string FIELD_DESCRIPTIONS = "DESCRIPTIONS";
        public const string FIELD_DELETED = "DELETED";
        public const string FIELD_RECORD_COUNT = "RecordCount";
        #endregion
        private string _connectionString;
        public DisabilityStatusBO(string connString)
        {
            this._connectionString = connString;
        }

        public DisabilityStatusBO()
        {
            this._connectionString = Common.ConnectionUtil.TKTHDS_METADATA_CONNECTION_STRING;

        }

        public DisabilityStatusDAO _DisabilityStatusDAO;
        public DisabilityStatusDAO CreateSQLDAO()
        {
            return new DisabilityStatusDAO(_connectionString, DEFAULT_MAPPER_TYPE);
        }

        public DisabilityStatusBO(string _connectionString, Type DEFAULT_MAPPER_TYPE)
        {
            // TODO: Complete member initialization

            this.DEFAULT_MAPPER_TYPE = DEFAULT_MAPPER_TYPE;
        }
        //-----------------------------------------------
        public DataPage<DisabilityStatusModel> GetDynamicListPaging(DisabilityStatusModel aModel, int pageSize, int pageIndex, bool compareEqual)
        {
            try
            {
                _DisabilityStatusDAO = CreateSQLDAO();
                Dictionary<String, String> mapDictionary = new Dictionary<string, string>()
                {
                    {DisabilityStatusModel.FIELD_DISABILITY_STATUS_ID,FIELD_DISABILITY_STATUS_ID},
                    {DisabilityStatusModel.FIELD_NAME,FIELD_NAME},
                    {DisabilityStatusModel.FIELD_CODE,FIELD_CODE},  
                    {DisabilityStatusModel.FIELD_DESCRIPTIONS,FIELD_DESCRIPTIONS},
                    {DisabilityStatusModel.FIELD_DELETED,FIELD_DELETED},
                    {DisabilityStatusModel.FIELD_RECORD_COUNT, FIELD_RECORD_COUNT}
                };
                return _DisabilityStatusDAO.GetDynamicListPaging(aModel, pageSize, pageIndex, mapDictionary, compareEqual);
            }
            catch (Exception)
            {
                throw;
            }
        }
        //----------------------------------------------------------
        public DisabilityStatusModel GetDisabilityStatusById(string id)
        {
            try
            {
                _DisabilityStatusDAO = CreateSQLDAO();

                Dictionary<String, String> mapDictionary = new Dictionary<string, string>()
                {
                    {DisabilityStatusModel.FIELD_DISABILITY_STATUS_ID,FIELD_DISABILITY_STATUS_ID},
                    {DisabilityStatusModel.FIELD_NAME,FIELD_NAME},
                    {DisabilityStatusModel.FIELD_CODE,FIELD_CODE},  
                    {DisabilityStatusModel.FIELD_DESCRIPTIONS,FIELD_DESCRIPTIONS},
                    {DisabilityStatusModel.FIELD_DELETED,FIELD_DELETED},
                    {DisabilityStatusModel.FIELD_RECORD_COUNT, FIELD_RECORD_COUNT}
                };

                return _DisabilityStatusDAO.GetById(id, mapDictionary);
            }
            catch (Exception)
            {
                throw;
            }
        }
        //----------------------------------------------------------------
        public bool createOrUpdateDisabilityStatus(DisabilityStatusModel model)
        {
            try
            {
                _DisabilityStatusDAO = CreateSQLDAO();

                return _DisabilityStatusDAO.createOrUpdateDisabilityStatus(model);
            }
            catch(Exception)
            { throw; }
        }
        //----------------------------------------------------------------
        public bool deleteDisabilityStatus(string[]Id)
        {
            try
            {
                _DisabilityStatusDAO = CreateSQLDAO();
                return _DisabilityStatusDAO.deleteDisabilityStatus(Id);
            }
            catch (Exception)
            { throw; }
        }
    }
}
